<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>
<body>
<div class="form-box">
    <div class="nav">
        <ul>
            <li>招聘岗位管理</li>
            <li>/</li>
            <li>添加岗位</li>
        </ul>
    </div>
    <div>
        <form id="addSolution">
            <div class="form-control">
                <label>岗位名称:</label>
                <input type="text" name="recruitName" id="recruitName">
            </div>
            <div class="form-control">
                <label>岗位描述:</label>
                <textarea rows="3" name="recruitDesc" id="recruitDesc" cols="60" class="textarea"></textarea>
            </div>
            <div class="form-control">
                <label>岗位要求:</label>
                <textarea rows="3" name="recruitRequirement" id="recruitRequirement" cols="60"
                          class="textarea"></textarea>
            </div>
            <div class="form-control">
                <label>图片</label>
                <input type="hidden" name="recruitImg" id="recruitImg">
                <input name="file" type="file" id="file"/>
                <!--贴图库Token-->
                <input name="Token" type="hidden" id="Token"
                       value="68gl3i8ak1kj495d92p76ri37iaork9l:1EBWt6slqN4v0mdjtTTQcBec6MY=:eyJkZWFkbGluZSI6MTY2MTE3MjcyOCwiYWN0aW9uIjoiZ2V0IiwidWlkIjoxNzc4MiwiYWlkIjoiMzMwMjYiLCJmcm9tIjoiZmlsZSJ9"/>
                <input type="button" value="上传" id="Upload"/>
                <!--显示添加的图片-->
                <div id="res"></div>
            </div>
            <div class="btn-box">
                <input type="button" value="提交">
                <input type="reset" value="重置">
            </div>
        </form>
    </div>
</div>
<script>
    //发送添加事物
    $("input[value='提交']").click(function () {
        var text1 = tinymce.editors[0].getContent();
        var text2 = tinymce.editors[1].getContent();
        $("#recruitDesc").val(text1);
        $("#recruitRequirement").val(text2);
        var info = $("#addSolution").serialize();
        $.post("/web/recruit", info + "&op=save", function (data) {
            if (data == '1') {
                $("#content").load("recruit/recruit-list.html");
                alert("添加成功")
            } else {
                $("#content").load("recruit/recruit-list.html");
                alert("添加失败")
            }
        });
    });
</script>
<!--贴图库-->
<script>
    //上传图片到贴图库，并保存图片url
    $("#Upload").click(function () {
        var formData = new FormData($('form')[0]);
        $.ajax({
            url: 'http://up.tietuku.cn/',
            type: 'POST',
            success: function (data) {
                $('#res').empty();
                $('#res').append(`<img src="${data.linkurl}" width="100px"/>`);
                $("#recruitImg").val(data.linkurl);
                alert("上传成功");
            },
            error: function (data) {
                console.log(data);
            },
            data: formData,
            cache: false,
            contentType: false,
            processData: false
        });
    });
</script>
<!--富文本框-->
<script>
    tinymce.init({
        selector: '.textarea', //容器，可使用css选择器
        language: 'zh_CN', //调用放在langs文件夹内的语言包
        toolbar: true, //工具栏
        menubar: true, //菜单栏
        branding: false, //右下角技术支持
        inline: false, //开启内联模式
        elementpath: false,
        min_height: 400, //最小高度
        height: 800,  //高度
        skin: 'oxide',
        toolbar_sticky: true,
        visualchars_default_state: true, //显示不可见字符
        image_caption: true,
        paste_data_images: true,
        relative_urls: false,
        // remove_script_host : false,
        removed_menuitems: 'newdocument',  //清除“文件”菜单
        plugins: "lists,hr, advlist,anchor,autolink,autoresize,charmap,code,codesample,emoticons,fullscreen,image,media,insertdatetime,link,pagebreak,paste,preview,print,searchreplace,table,textcolor,toc,visualchars,wordcount", //依赖lists插件
        toolbar: 'bullist numlist anchor charmap emoticons fullscreen hr image insertdatetime link media pagebreak paste preview print searchreplace textcolor wordcount',
        //选中时出现的快捷工具，与插件有依赖关系
        images_upload_url: 'a.php', /*后图片上传接口*/ /*返回值为json类型 {'location':'uploads/jpg'}*/
        setup: function (editor) {
            editor.on('change', function () {
                editor.save();
            });
        }
    });
</script>
</body>
</html>